package fire;

import java.awt.event.KeyEvent;
import fire.button.ContinueButton;
import fire.button.QuitButton;
import fire.button.StartButton;
import fire.chacracter.Player;
import fire.room.Map;
import jgame.JGColor;
import jgame.JGPoint;
import jgame.platform.JGEngine;
import jgame.platform.JREEngine;

public class Main extends JGEngine {
	private static Player player;
	private static QuitButton q;
	private static ContinueButton c;
	private static StartButton s;
	private static Map map;
	private static Main main;

	public Main(JGPoint size) {
		initEngine(size.x, size.y);
	}

	public Main() {
		initEngineApplet();
	}

	public static void main(String[] args) {
		main = new Main(new JGPoint(0, 0));
	}

	@Override
	public void initCanvas() {
		// we set the background colour to same colour as the splash background
		setCanvasSettings(65, 48, 16, 16, null, null, null);
	}

	@Override
	public void initGame() {
		setFrameRate(35, 2);
		defineMedia("setting/test.tbl");	
		setBGImage(0, "background", true, true);
//		map = new Map("setting/test.tbl", "setting/test.oom", 200, 200);
//		map.createMap(main);
//		// setPFWrap(true, true, 0, 0);
//		// player = new Player("player", 200, 200, "player_d", 3);
//		s = new StartButton("start", 225, 210, 8000, "start");
//		c = new ContinueButton("continue", 225, 295, 300, "continue");
//		q = new QuitButton("quit", 225, 380, 400, "quit");
	}

	public void doFrame() {
//		map.updateView(this);
		// Move all objects.
		moveObjects(null, 0);

	}

	public static void changeMap(Map newMap) {
//		s.remove();
//		q.remove();
//		c.remove();

		map = newMap;
		map.createMap(main);
	}

	public void paintFrame() {
		if (getKey(KeyEvent.VK_Q)) {
			setBGImage(0, "clone", true, true);
		}
		if (getKey(KeyEvent.VK_E)) {
			changeMap(new Map("setting/test1.tbl", "setting/test1.oom",
					200, 200));
		}
	}

	public Map getMap() {
		return map;
	}

	public void setMap(Map map) {
		this.map = map;
	}

	public Player getPlayer() {
		return player;
	}

	public void setPlayer(Player player) {
		this.player = player;
	}
}
